home *** CD-ROM | disk | FTP | other *** search
- /*
- HOW TO USE IoctlSocket()
- */
-
- parse arg dev
-
- if ~show("L","rexxsupport.library") then
- if ~addlib("rexxsupport.library",0,-30) then do
- say "no rexxsupport.library"
- exit
- end
- if ~show("L","rxsocket.library") then
- if ~addlib("rxsocket.library",0,-30) then do
- say "no rxsocket.library"
- exit
- end
- if ~show("L","rmh.library") then
- if ~addlib("rmh.library",0,-30) then do
- say "no rmh.library"
- exit
- end
-
- s=socket("INET","DGRAM")
- if s<0 then do
- call err "socket"
- exit
- end
-
- /* SET the socket as async */
- res = IoctlSocket(s,"FIOASYNC",1)
- if res<0 then call error "FIOASYNC"
- else say "socket is FIOASYNC"
-
- /* SET the socket as non blocking */
- res = IoctlSocket(s,"FIONBIO",1)
- if res<0 then call error "FIONBIO"
- else say "socket is FIONBIO"
-
-
-
- /* CHECK if at OOB */
- res = IoctlSocket(s,"SIOCATMARK","A")
- if res<0 then call error "SIOCATMARK"
- else say "SIOCATMARK:" a
-
- /* GET number of bytes ready to be read */
- res = IoctlSocket(s,"FIONREAD","A")
- if res<0 then call error "FIONREAD"
- else say "FIONREAD:" a
-
-
- /* GET vaious interface attributes*/
- res = IoctlSocket(s,"SIOCGIFADDR",dev,"A")
- if res<0 then say call error "SIOCGIFADDR"
- else say "SIOCGIFADDR:" a
-
- res = IoctlSocket(s,"SIOCGIFDSTADDR",dev,"A")
- if res<0 then call error "SIOCGIFDSTADDR"
- else say "SIOCGIFDSTADDR:" a
-
- res = IoctlSocket(s,"SIOCGIFBRDADDR",dev,"A")
- if res<0 then call error "SIOCGIFBRDADDR"
- else say "SIOCGIFBRDADDR:" a
-
- res = IoctlSocket(s,"SIOCGIFNETMASK",dev,"A")
- if res<0 then call error "SIOCGIFNETMASK"
- else say "SIOCGIFNETMASK:" a
-
- res = IoctlSocket(s,"SIOCGIFFLAGS",dev,"A")
- if res<0 then call error "SIOCGIFFLAGS"
- else say "SIOCGIFFLAGS:" a
-
- res = IoctlSocket(s,"SIOCGIFMETRIC",dev,"A")
- if res<0 then call error "SIOCGIFMETRIC"
- else say "SIOCGIFMETRIC:" a
-
- res = IoctlSocket(s,"SIOCGIFMTU",dev,"A")
- if res<0 then call error "SIOCGIFMTU"
- else say "SIOCGIFMTU:" a
-
- res = IoctlSocket(s,"SIOCGIFPHYS",dev,"A")
- if res<0 then call error "SIOCGIFPHYS"
- else say "SIOCGIFPHYS:" a
-
- exit
-
- error:
- parse arg attr
- e=errno()
- if IsLibOn("TTCP") then say "error on" attr":" e
- else say "error on" attr":" errorstring(e)
- return
-